\section{Configuration}
\label{konfiguration}
The configuration of the EEPROM-emulation must be done at two locations. In the header file \textit{hybrid\_ftl.h} the organization of the memory chips as well as general parameters of the system are defined. See table \ref{tab:headerconfig}

\begin{table}[htb]
	\centering
		\begin{tabular}{|l|p{8cm}|}\hline
			
			\textbf{Variable} & \textbf{Description} \\\hline
			SECTOR\_COUNT & number of erasable units (sectors) of the flash-chips \\\hline
			PAGES\_PER\_SECTOR & number of pages per sector \\\hline
			BYTES\_PER\_PAGE & number of bytes per page \\\hline
			ERASE\_COUNT\_THRESHOLD & threshold before the wear-leveling-algorithm will be activated\\\hline
			CACHE\_SIZE & the size of the header-cache - for each affected sector two cache slots should be provided\\\hline
		\end{tabular}
	\caption{Configuration per header file}
	\label{tab:headerconfig}
\end{table}

The following settings are valid for the N25Q032A Micron and Spansion S25FL032P:

\lstset{language=C}
\begin{lstlisting}[frame=single]
#define SECTOR_COUNT		64
#define PAGES_PER_SECTOR	256
#define BYTES_PER_PAGE		256
#define ERASE_COUNT_THRESHOLD	10
#define CACHE_SIZE		5
\end{lstlisting}

To make the low-level functions known to the EEPROM emulator, the pointer to them will be passed to the local handler. A listing of the required low-level functions are shown in Table \ref{tab:funktionen}. Then, the handler must be registered. The function \textit{FTL001\_RegisterHandler} is defined as follows:

\begin{mdframed}\begin{tabbing}
	\hspace{1cm} \= \hspace{1cm} \= \hspace {1.5cm} \= \kill
	FTL001\_StatusType \textbf{FTL001\_RegisterHandler} \\
	\>\> (FTL001\_HandleType*  Handle, FTL001\_Handler* Handler) \\
	\\
	\> Registers the handler value with the low-level-functions to the system. \\
	\\
	\> \textbf{Parameter:} \\
	\>\> Handle - Pointer to the global handler (FTL001\_Handle0 is the\\
	\>\>\> predefined global one) \\
	\>\> Handler - Pointer to the local handler with allocated pointer to\\
	\>\>\> low-level-functions \\
	\> \textbf{Returns:} \\
	\>\> FTL001\_StatusType - Errorcode
\end{tabbing}\end{mdframed}

\newpage

A short example for the N25Q032A:

\begin{lstlisting}[frame=single]
Handler.ReadID = N25Q032A_RDID;
Handler.ProgramPage = N25Q032A_QuadWrite_PAGE;
Handler.WriteEnable = N25Q032A_WriteEnable;
Handler.ReadStatus = N25Q032A_STATUS_RD;
Handler.ReadPage = N25Q032A_QuadRD_PAGE;
Handler.SectorErase = N25Q032A_Sector_Erase;
Handler.ConfigureStandard = N25Q032A_Std_Config;

FTL001_RegisterHandler(&FTL001_Handle0, &Handler);
\end{lstlisting}

\begin{table}[htb]
	\centering
		\begin{tabular}{|p{3.5cm}|p{5cm}|p{6cm}|}\hline
		
			\textbf{Return datatype} & \textbf{Variable / Parameter} & \textbf{Description} \\\hline
		
				FTL001\_StatusType & ReadID & read out the CFI-informations \\\cline{3-3}
				& (uint16\_t *pSPIReceiveData) & pointer to variable for CFI-informations \\\hline

				FTL001\_StatusType & WriteEnable	& disable write protection \\\cline{3-3}
				& (void) & no parameter \\\hline

				uint16\_t	& ReadStatus & read status register \\\cline{3-3}
				& (void) & no parameter \\\hline	
				
				FTL001\_StatusType & ProgramPage	& write page \\\cline{3-3}
				& (uint32\_t Address, & memory adress \\\cline{3-3}
				& uint8\_t* pBuf) &	pointer to array of bytes \\\hline
				
				FTL001\_StatusType & ReadPage & read page \\\cline{3-3}
				& (uint32\_t Address, & memory address \\\cline{3-3}
				& uint8\_t* pBuf) & pointer to array of bytes \\\hline
				
				FTL001\_StatusType & SectorErase	& erase sector \\\cline{3-3}
				& (uint32\_t Address) & memory address \\\hline

				FTL001\_StatusType & ConfigureStandard	& standard configuration for the flash chip\\\cline{3-3}
				& (void) & no parameter \\\hline
		\end{tabular}
	\caption{low-level-functions}
	\label{tab:funktionen}
\end{table}
